package com.diandian.backend.dingding.data.controller;

import com.diandian.backend.dingding.data.service.DingdingDeptTreeStaffService;
import com.diandian.base.boot.starter.response.BaseResult;
import com.diandian.base.boot.starter.util.ResultUtil;
import com.diandian.backend.dingding.data.param.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * [钉钉]部门树员工关联表
 */
@RestController
@RequestMapping("/dept/tree/staff")
public class DingdingDeptTreeStaffController{

    @Autowired
    private DingdingDeptTreeStaffService iDingdingDeptTreeStaffService;

    /**
    * 分页查询
    */
    @PostMapping("/page")
    public BaseResult page(@RequestBody DingdingDeptTreeStaffPageParam param) {
        param.check();
        return ResultUtil.makeResult(iDingdingDeptTreeStaffService.page(param.toDTO()));
    }

    /**
     * 2. 查询详情
     */
    @PostMapping("/detail")
    public BaseResult getDetail(@RequestBody DingdingDeptTreeStaffDetailParam param) {
        return ResultUtil.makeResult(iDingdingDeptTreeStaffService.getDetail(param.toDTO()));
    }

    /**
     * 3. 根据数据id更新数据
     */
    @PostMapping("/updateById")
    public BaseResult updateById(@RequestBody DingdingDeptTreeStaffUpdateByIdParam param) {
        iDingdingDeptTreeStaffService.updateById(param.toDTO());
        return ResultUtil.makeResult();
    }

    /**
     * 4. 根据数据id删除数据
     */
    @PostMapping("/deleteById")
    public BaseResult deleteById(@RequestBody DingdingDeptTreeStaffDeleteByIdParam param) {
        param.check();
        iDingdingDeptTreeStaffService.deleteById(param.toDTO());
        return ResultUtil.makeResult();
    }

    /**
     * 5. 新增
     */
    @PostMapping("/add")
    public BaseResult add(@RequestBody DingdingDeptTreeStaffAddParam param) {
        iDingdingDeptTreeStaffService.add(param.toDTO());
        return ResultUtil.makeResult();
    }

    /**
     * 7. 列表查询
     */
    @PostMapping("/list")
    public BaseResult list(@RequestBody DingdingDeptTreeStaffListParam param) {
        return ResultUtil.makeResult(iDingdingDeptTreeStaffService.getList(param.toDTO()));
    }

}